package com.ruoyi.common.utils.sms;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;

public class SmsUtil {

    private static final String SMS_CODE_MESSAGE = "【春丽正达医疗】您好，您的验证码是：%s，请在5分钟内有效，非本人操作请忽略。";
    private static final String SMS_MESSAGE = "【春丽正达医疗】%s";

    private static final String SMS_URL = "http://59.110.24.249:8090/send.do";

    private static final String SMS_UID = "2619";

    private static final String SMS_PW = "A3B9F7C7";

    public static String sendSmsCode(String code,String smsMessage,String phone){
        if(StringUtils.isBlank(smsMessage)){
            smsMessage = SMS_CODE_MESSAGE;
        }
        String message = String.format(smsMessage, code);
        String param = String.format("uid=%s&pw=%s&mb=%s&ms=%s&ex=77",SMS_UID, SMS_PW,phone,message);
        String result = HttpUtils.sendGet(SMS_URL, param);
        return result;
    }

    public static String sendSms(String mess,String smsMessage,String phone){
        if(StringUtils.isBlank(smsMessage)){
            smsMessage = SMS_MESSAGE;
        }
        String message = String.format(smsMessage,mess);
        String param = String.format("uid=%s&pw=%s&mb=%s&ms=%s&ex=77",SMS_UID, SMS_PW,phone,message);
        String result = HttpUtils.sendGet(SMS_URL, param);
        return result;
    }

    public static void main(String[] args) {
        sendSmsCode("123456",SMS_CODE_MESSAGE,"17600299327");
    }
}
